/*
 * @Title: 填写订单 - 新增拼团填写订单
 * @Author: JSL、zhuhaojie
 * @Date:   2018-10-13
 * @Last Modified by:   JSL
 * @Last Modified time: 2018-11-13
 */

var dataInfo = new Object(),
  template = {
    init: function() {
      dataInfo.init = new Vue({
        el: '#app',
        data: {
          show: false,
          type: false, //判断用户是否有默认地址
          isWx: is_weixn(),
          isDz: '',
          radio: is_weixn() ? '4' : '5', //4 - wx , 5 - zfb
          payAmount: 0, //支付金额
          remark: '',
          addressid: !getQueryString('addressId') ? '' : getQueryString('addressId'), //地址列表返回id
          buyWay: !getQueryString('buyWay') || getQueryString('buyWay') == 1 ? 1 : getQueryString('buyWay') == 3 ? 3 : 2, //1-立即购买 2-购物车 3-拼团
          grouponGoodsVirtualId: getQueryString('grouponGoodsVirtualId'), //拼团主商品ID
          grouponGoodsItemId: getQueryString('grouponGoodsItemId'), //拼团子商品ID
          activityId: !!getQueryString('activityId') ? getQueryString('activityId') : '', //拼团活动ID - 判定id 有无拼团都有！！！
          isJoin: getQueryString('isJoin') == 1 || getQueryString('isJoin') == 'T' ? 'T' : !!getQueryString('activityId') ? 'F' : '', //是否是参团 ‘T’ 是 ‘F’否
          groupId: !!getQueryString('groupId') ? getQueryString('groupId') : '', //拼团号，如果是参团，请传拼团ID
          goodsInfo: {
            orderCouponsCode: '', //优惠券code 需自己计算
            goodsItem: []
          },
          list: [], //商品信息列表
          pUserId: shareUserId, //推荐人id
          isGiftPacksOrder: !getQueryString('isGiftPacksOrder') || getQueryString('isGiftPacksOrder') == 'null' ? 1 : 0, //是否是大礼包:0-是 1-否
          orderData: !!getQueryString('orderData') ? JSON.parse(unescape(getQueryString('orderData'))) : {}, //先确保正常购买-再验证二次登录
          orderDataForAdress: !!getQueryString('addressId') ? unescape(getCookie('zmtMallOrder')) : JSON.stringify([JSON.parse(getQueryString('orderData'))]),
          address: [], //回显的地址信息
          addAdress: { //提交的地址信息
            userId: userId,
            name: '',
            phone: '',
            province: '',
            city: '',
            district: '',
            address: '',
            defaultAddress: 0
          },
          submitSwitch: 1,
          orderId: '', //订单id
          activityType: '', //
          aliPay: '', //alipay回调方法
          openid: openId,
          wxInfo: {},
          areaList: addressInfo,
          showCoupon: false, //优惠券弹窗
          couponIndex: 0, //用户选择优惠券的下标 默认第一个

          goodsFullStr: '', //H5优惠券 新增参数
          couponsV3: [], //单品优惠券列表
          showCouponV3: 0,
          couponsV3CIndex: '', //选中的单品优惠下标
          couponsV3CNum: '', //选中的单品优惠code
          couponsGoodsInfo: {
            orderCouponsCode: '', //优惠券code 需自己计算
            goodsItem: []
          },

        },
        methods: {
          choseOver: function(data) { //用户选择地址结束
            this.addAdress.province = data[0].name;
            this.addAdress.city = ' ' + data[1].name + ' ';
            this.addAdress.district = data[2].name;
            this.show = false;
          },
          getDefaulAddressByUser: function() { //获取默认地址
            ajaxTemplate(addressTest + SERVICE.getDefaulAddressByUser, function(data) {
              if (data.tag == 0) {
                if (data.data.result.length == 0) {
                  dataInfo.init.type = false;
                } else {
                  dataInfo.init.type = true;
                  dataInfo.init.addressid = data.data.result[0].id;
                  dataInfo.init.address = data.data.result;
                };
                dataInfo.init.$toast.clear();
              } else {
                dataInfo.init.$toast.clear();
                dataInfo.init.$toast(data.errMsg);
              };
              dataInfo.init.initProductInfo();
            }, {
              userId: userId
            });
          },
          getAddressDetails: function() { //获取默认地址 - 外部跳转来的
            ajaxTemplate(addressTest + SERVICE.getOrderDetails, function(data) {
              if (data.tag == 0) {
                dataInfo.init.type = true;
                dataInfo.init.addressid = data.data.result[0].id;
                dataInfo.init.address = data.data.result;
                dataInfo.init.$toast.clear();
              } else {
                dataInfo.init.$toast.clear();
                dataInfo.init.$toast(data.errMsg);
              };
              dataInfo.init.initProductInfo();
            }, {
              userId: userId,
              id: this.addressid
            });
          },
          saveAddress: function() { //新增默认地址
            if (!this.addAdress.name || !this.addAdress.name.trim()) {
              this.$toast('请输入收货人姓名');
            } else if (!this.addAdress.phone) {
              this.$toast('请输入收货人手机号');
            } else if (!(/^1[0-9]\d{9}$/.test(this.addAdress.phone))) {
              this.$toast('请输入正确的手机号');
            } else if (!this.addAdress.district) {
              this.$toast('请选择收货区域');
            } else if (!this.addAdress.address || !this.addAdress.address.trim()) {
              this.$toast('请输入详细地址');
            } else {
              this.$toast.loading({
                forbidClick: true,
                message: '收货信息提交中...',
                loadingType: 'spinner',
                duration: 0,
              });
              ajaxTemplate(addressTest + SERVICE.addAddressOrder, function(data) {
                console.log(data);
                if (data.tag == 0) {
                  dataInfo.init.getDefaulAddressByUser();
                } else {
                  dataInfo.init.$toast.clear();
                  dataInfo.init.$toast(data.errMsg);
                };
              }, JSON.parse(JSON.stringify(this.addAdress)));
            };
          },
          getOrderInfo: function() { //获取购物车信息
            ajaxTemplate(addressUrl + SERVICE.getCacheCartGoods, function(data) {
              if (data.tag == 0) {
                // dataInfo.init.orderData = JSON.parse(data.data.result.value); //商品信息回显
                dataInfo.init.orderDataForAdress = data.data.result.value;
                dataInfo.init.getPtCoupon(4);
              } else {
                dataInfo.init.$toast.clear();
                dataInfo.init.$toast(data.errMsg);
              };
            }, {
              uuid: JSON.parse(unescape(getCookie('zmtMallOrder')))
            });
          },
          submitH5Order: function() { //提交订单
            if (!this.type) {
              this.$toast('请填写收货地址');
            } else {
              dataInfo.init.$toast.loading({
                forbidClick: true,
                message: '数据提交中...',
                loadingType: 'spinner',
                duration: 0,
              });
              this.submitData.isShop = this.isDz;
              console.log(this.submitData);
              if (this.submitSwitch == 1) {
                this.submitSwitch = 2;
                !!this.activityId ? dataInfo.submitUrl = addressTest + SERVICE.ptSubmit : dataInfo.submitUrl = addressUrl + SERVICE.submitH5Order;
                ajaxTemplate(dataInfo.submitUrl, function(data) {
                  console.log(data);
                  if (data.tag == 0) {
                    dataInfo.init.orderId = data.data.result.orderId;
                    if (!!dataInfo.init.activityId && dataInfo.init.orderData.activityType == 'new_guest_pt_groupon') { //拼团校验
                      //拼团校验是否是新手团
                      //common_pt_groupon 普通团
                      //new_guest_pt_groupon 新手团
                      //colonel_free_pt_groupon 团长免单团
                      dataInfo.init.verifyIdentity();
                    } else if (!!dataInfo.init.activityId && data.data.result.isNeedPay == 1) { //团长免单券 不需要支付
                      dataInfo.init.toPay(data.data.result.isNeedPay);
                    } else { //正常支付
                      dataInfo.init.toPay();
                    };
                  } else {
                    dataInfo.init.$toast.clear();
                    // dataInfo.init.$toast(data.errMsg);
                    dataInfo.init.$dialog.alert({
                      message: data.errMsg
                    }).then();
                  };
                  dataInfo.init.submitSwitch = 1;
                }, this.submitData);
              };
            };
          },
          verifyIdentity: function() { //拼团校验是否是新手团
            ajaxTemplate(addressTest + SERVICE.verifyIdentity, function(data) {
              console.log(data);
              if (data.tag == 0) {
                if (data.data.result.isNewMan == 0) {
                  dataInfo.init.$toast.clear();
                  dataInfo.init.$toast('该商品仅限新用户购买');
                } else {
                  dataInfo.init.toPay();
                };
                dataInfo.init.submitSwitch = 1;
              } else {
                dataInfo.init.$toast.clear();
                dataInfo.init.$toast(data.errMsg);
              };
            }, {
              userid: userId,
              orderid: dataInfo.init.orderId
            });
          },
          getPtCoupon: function() { // 获取拼团优惠券 - 优惠券初始化  增加邮费验证
            // orderforh5
            ajaxTemplate(addressUrl + SERVICE.orderforh5V3, function(data) {
              console.log('邮费校验');
              console.log(data);
              console.log(data.data.result.coupons);
              if (data.tag == 0) {
                dataInfo.init.goodsFullStr = data.data.result.goodsFullStr;
                dataInfo.init.orderData = data.data.result;
                if (dataInfo.init.orderData.orderFullList.length > 0) {
                  dataInfo.init.orderData.orderFullList.forEach(function(item, index) {
                    if (item.selected == 0) {
                      dataInfo.init.couponIndex = index;
                      dataInfo.init.goodsInfo.orderCouponsCode = item.code;
                    };
                  });
                };
              } else {
                dataInfo.init.$toast.clear();
                dataInfo.init.$toast(data.errMsg);
              };
              dataInfo.init.submitSwitch = 1;
            }, {
              userId: userId,
              isGiftPacksOrder: this.isGiftPacksOrder,
              // goodsInfo: JSON.stringify([JSON.parse(this.orderDataForAdress)]), //变更订单回显接口后无影响
              goodsInfo: this.orderDataForAdress,
              addressId: this.addressid,
              activityId: this.activityId,
              isJoin: this.isJoin,
            });
          },
          getCouponsV3: function(index, code, num, goodsCode, isKill) { //查询单品优惠券接口
            this.couponsV3CIndex = index;
            if (dataInfo.getCouponsV3Switch == 1) {
              dataInfo.getCouponsV3Switch = 2;
              ajaxTemplate(addressUrl + SERVICE.getCouponsV3, function(data) {
                console.log('单品优惠券列表');
                console.log(data);
                if (data.tag == 0) {
                  dataInfo.init.couponsV3 = data.data.result;
                  dataInfo.init.couponsV3.length > 0 ? dataInfo.init.couponsV3CNum = code : '';
                  dataInfo.init.showCouponV3 = 1;
                } else {
                  dataInfo.init.$toast.clear();
                  dataInfo.init.$toast(data.errMsg);
                };
                dataInfo.getCouponsV3Switch = 1;
              }, {
                userId: userId,
                code: code,
                goodsFullStr: this.goodsFullStr,
                goodsCode: goodsCode,
                num: num,
                isKill: isKill
              });
            };
          },
          chanceUpdV3: function() { //更改订单优惠券
            if (dataInfo.getCouponsV3Switch == 1) {
              dataInfo.getCouponsV3Switch = 2;
              ajaxTemplate(addressUrl + SERVICE.chanceUpdV3, function(data) {
                console.log('更改优惠券');
                console.log(data);
                if (data.tag == 0) {
                  dataInfo.init.goodsFullStr = data.data.result.goodsFullStr;
                  dataInfo.init.orderData = data.data.result;
                  dataInfo.init.orderData.orderFullList.length > 0 ? dataInfo.init.goodsInfo.orderCouponsCode = dataInfo.init.orderData.orderFullList[dataInfo.init.couponIndex].code : '';
                } else {
                  dataInfo.init.$toast.clear();
                  dataInfo.init.$toast(data.errMsg);
                };
                dataInfo.getCouponsV3Switch = 1;
              }, {
                userId: userId,
                goodsInfo: UrlEncode(JSON.stringify(this.couponsGoodsInfo)),
                addressId: this.addressid
              });
            };
          },
          isCouponVerify: function() {
            //购物车购买无法选择优惠券问题 - 待修复 181229
            this.couponsGoodsInfo.orderCouponsCode = this.goodsInfo.orderCouponsCode;
            this.couponsGoodsInfo.goodsItem = [];
            dataInfo.couponsListNum = 0;
            this.list.forEach(function(itm, inx) {
              itm.packList.forEach(function(item, index) {
                console.log(item);
                dataInfo.init.couponsGoodsInfo.goodsItem[dataInfo.couponsListNum] = {};
                dataInfo.init.couponsGoodsInfo.goodsItem[dataInfo.couponsListNum].goodsCode = item.goodsCode;
                dataInfo.init.couponsGoodsInfo.goodsItem[dataInfo.couponsListNum].num = item.num;
                dataInfo.init.couponsGoodsInfo.goodsItem[dataInfo.couponsListNum].code = item.code;
                dataInfo.init.couponsGoodsInfo.goodsItem[dataInfo.couponsListNum].isKill = item.isKill;
                dataInfo.init.couponsGoodsInfo.goodsItem[dataInfo.couponsListNum].killCode = item.killCode;
                dataInfo.couponsListNum += 1;
              });
            });
            // this.list[0].packList.forEach(function(item, index) {
            //   console.log(item);
            //   dataInfo.init.couponsGoodsInfo.goodsItem[dataInfo.couponsListNum] = {};
            //   dataInfo.init.couponsGoodsInfo.goodsItem[dataInfo.couponsListNum].goodsCode = item.goodsCode;
            //   dataInfo.init.couponsGoodsInfo.goodsItem[dataInfo.couponsListNum].num = item.num;
            //   dataInfo.init.couponsGoodsInfo.goodsItem[dataInfo.couponsListNum].code = item.code;
            //   dataInfo.init.couponsGoodsInfo.goodsItem[dataInfo.couponsListNum].isKill = item.isKill;
            //   dataInfo.init.couponsGoodsInfo.goodsItem[dataInfo.couponsListNum].killCode = item.killCode;
            //   dataInfo.couponsListNum += 1;
            // });
          },
          isCouponV3: function() { //选择单品优惠券
            this.isCouponVerify();
            this.couponsGoodsInfo.goodsItem[this.couponsV3CIndex].code = this.couponsV3CNum;
            this.chanceUpdV3();
            this.showCouponV3 = !this.showCouponV3;
          },
          isCouponV4: function() { //选择满减优惠券
            this.isCouponVerify();
            this.chanceUpdV3();
            this.showCoupon = !this.showCoupon;
          },
          toPay: function(isNeedPay) {
            dataInfo.returnUrl = window.location.href.split('/html/')[0] + '/html/';
            dataInfo.returnUrl += !!this.activityId ? 'PtPaySuccess' : 'orderFinish';
            dataInfo.returnUrl += '.html?orderId=' + this.orderId + '&groupId=' + this.groupId + '&activityType=' + this.activityType + '&virtualgoodsID=' + this.orderData.goodsList[0].virtualGoodsCode + '&activityId=' + this.activityId;
            dataInfo.payInfo = new Object();
            dataInfo.payInfo.orderId = this.orderId;
            dataInfo.payInfo.ptType = 'fx';
            dataInfo.init.radio == '4' ? dataInfo.payInfo.channel = 'h5fxcwx' : dataInfo.payInfo.channel = 'h5fxcali';
            dataInfo.init.radio == '4' ? dataInfo.payInfo.openid = this.openid : dataInfo.payInfo.returnUrl = dataInfo.returnUrl;
            if (!!dataInfo.init.activityId && !!isNeedPay && isNeedPay == 1) { //团长免单券 不需要支付
              location.href = dataInfo.returnUrl;
            } else if (!!this.isWx && (window.location.href.indexOf('mtmall.meetao.com') != 8)) { //微信支付跳转第三方
              //版本号1.1 没有拼团数据
              //1 - 普通支付（分销商品、大礼包）、 2 - 普通订单支付 、3 - 拼团支付 、 4 - 拼团订单支付
              //181128 - 增加灰度拼团跳转
              !!this.activityId ? dataInfo.payType = 3 : dataInfo.payType = 1;
              location.href = 'https://premtmall.meetao.com/html/WxPay.html?mallUrl=' + window.location.href.split('/html/')[0] + '&ajaxUrl=' + addressPayUrl + '&orderId=' + this.orderId + '&openid=' + this.openid + '&groupId=' + this.groupId + '&activityType=' + this.activityType + '&virtualgoodsID=' + this.orderData.goodsList[0].virtualGoodsCode + '&activityId=' + this.activityId + '&payType=' + dataInfo.payType;
            } else {
              ajaxTemplate(addressPayUrl + SERVICE.payUrl, function(data) {
                console.log(data);
                if (data.tag == 0 && dataInfo.init.radio == '4') { //wxPay
                  dataInfo.init.wxInfo = data.data.result;
                  if (typeof WeixinJSBridge == "undefined") {
                    if (document.addEventListener) {
                      document.addEventListener('WeixinJSBridgeReady', dataInfo.init.onBridgeReady(data.data.result), false);
                    } else if (document.attachEvent) {
                      document.attachEvent('WeixinJSBridgeReady', dataInfo.init.onBridgeReady(data.data.result));
                      document.attachEvent('onWeixinJSBridgeReady', dataInfo.init.onBridgeReady(data.data.result));
                    }
                  } else {
                    console.log(data.data.result);
                    dataInfo.init.onBridgeReady(data.data.result);
                  };
                } else if (data.tag == 0 && dataInfo.init.radio == '5') { //alipay
                  dataInfo.init.aliPay = decodeURIComponent(data.data.result.sign.replace(/\+/g, " "));
                  setTimeout(function() {
                    document.forms[0].submit();
                  }, 250);
                } else {
                  //pt外部分享支付 有可能存在无openid问题 支付不成功需打开此处注释
                  // alert('2接口地址' + addressPayUrl + SERVICE.payUrl);
                  // alert(JSON.stringify(dataInfo.payInfo));
                  // alert(JSON.stringify(data));
                  dataInfo.init.$toast.clear();
                  dataInfo.init.$toast(data.errMsg);
                };
                dataInfo.init.submitSwitch = 1;
              }, dataInfo.payInfo);
            }
          },
          onBridgeReady: function(msg) { //wxPay
            dataInfo.init.$toast.clear();
            WeixinJSBridge.invoke(
              'getBrandWCPayRequest', {
                "appId": msg.appId, //公众号名称，由商户传入
                "timeStamp": msg.timeStamp, //时间戳，自1970年以来的秒数
                "nonceStr": msg.nonceStr, //随机串
                "package": msg.package_str,
                "signType": "MD5", //微信签名方式：
                "paySign": msg.paySign //微信签名
              },
              function(res) {
                console.log(res);
                if (res.err_msg == "get_brand_wcpay_request:ok") { //微信支付成功 - 支付成功页面
                  !!dataInfo.init.activityId ? location.href = dataInfo.returnUrl : location.href = '../html/orderFinish.html?orderId=' + dataInfo.init.orderId;
                } else { //微信支付失败跳转我的订单页面
                  !!dataInfo.init.activityId ? location.href = '../html/PtOrderDetails.html?orderId=' + dataInfo.init.orderId + '&groupId=' + dataInfo.init.groupId : location.href = '../html/orderDetails.html?orderId=' + dataInfo.init.orderId;
                };
              });
          },
          getDzInfo: function() { //验证是否为店主
            ajaxTemplate(addressUrl + SERVICE.isDz, function(data) {
              console.log(data);
              if (data.tag == 0) { //是否店主:0-是 1-否 (小程序传否)
                data.data.result.userRole > 2 ? dataInfo.init.isDz = 0 : dataInfo.init.isDz = 1;
              } else {
                dataInfo.init.isDz = 1;
              };
            }, {
              userId: userId,
              uId: userId
            });
          },
          toAddressList: function() { //跳转地址列表
            if (!!this.activityId) { //立即购买 - 拼团
              this.buyWay = 3;
              !getQueryString('addressId') ? dataInfo.zmtMallPtOrder = window.location.href.split('html/orderFilling.html?')[1] : dataInfo.zmtMallPtOrder = 'orderData=' + window.location.href.split('&orderData=')[1];
              setCookie('zmtMallPtOrder', escape(dataInfo.zmtMallPtOrder), 30); //拼团数据特殊化处理
            } else if (!dataInfo.init.addressid && !!getQueryString('orderData')) { //立即购买 - fx商品、大礼包
              // setCookie('zmtMallOrder', escape(JSON.stringify(this.orderData)), 30);
            };
            //==2为拼团 拼团保存的是id 不是商品数据
            this.buyWay == 2 ? '' : setCookie('zmtMallOrder', escape(this.orderDataForAdress), 30);
            location.href = '../html/addressList.html?from=orderFilling.html&buyWay=' + this.buyWay;
          },
          initProductInfo: function() { //判断入口页面 并对应初始化
            if (!!dataInfo.init.activityId || dataInfo.init.buyWay == 3) { //拼团 」
              dataInfo.init.getPtCoupon(0); //拼团查询优惠券
            } else if (dataInfo.init.buyWay == 2) { //购物车
              dataInfo.init.getOrderInfo();
            } else if (!!getQueryString('orderData')) { //直接购买 』
              // dataInfo.init.orderData = JSON.parse(unescape(getQueryString('orderData'))); //商品信息回显
              dataInfo.init.getPtCoupon(1); //直接购买查询数据
            } else { //填写地址 - 回显 」
              // dataInfo.init.orderData = JSON.parse(unescape(getCookie('zmtMallOrder')));
              dataInfo.init.getPtCoupon(2); //直接购买查询数据
            };
          },
        },
        computed: {
          submitData: function() { //提交订单总数据
            dataInfo.submitData = new Object();
            dataInfo.submitData.userId = userId;
            dataInfo.submitData.remark = this.remark;
            dataInfo.submitData.addressId = this.addressid;
            dataInfo.submitData.payChannel = this.radio;
            !!this.activityId && !!this.orderData.orderFullList && this.orderData.orderFullList.length > 0 ? this.goodsInfo.orderCouponsCode = this.orderData.orderFullList[this.couponIndex].code : '';
            dataInfo.submitData.payAmount = this.orderData.payAmount;
            if (!!this.activityId) { //拼团
              dataInfo.submitData.grouponGoodsVirtualId = this.grouponGoodsVirtualId;
              dataInfo.submitData.grouponGoodsItemId = this.grouponGoodsItemId;
              dataInfo.submitData.activityId = this.activityId;
              dataInfo.submitData.isJoin = this.isJoin;
              this.goodsInfo.goodsItem[0].oldprice = this.goodsInfo.goodsItem[0].packList[0].marketPrice;
              dataInfo.submitData.goodsInfo = JSON.stringify(this.goodsItemV2);
              !!this.groupId ? dataInfo.submitData.groupId = this.groupId : '';
              dataInfo.submitData.Type = 'J';
            } else { //正常购买
              dataInfo.submitData.buyWay = this.buyWay;
              dataInfo.submitData.pUserId = this.pUserId;
              dataInfo.submitData.isGiftPacksOrder = this.isGiftPacksOrder;
              dataInfo.submitData.isShop = this.isDz;
              dataInfo.submitData.goodsInfo = UrlEncode(JSON.stringify(this.goodsItemV2));
            };
            return dataInfo.submitData;
          },
          goodsItemV2: function() { //代发货更换接口后前端重新整理数组
            dataInfo.goodsItemV2 = [];
            dataInfo.goodsItemV2Object = {};
            this.goodsInfo.goodsItem.forEach(function(item, index) {
              index == 0 ? item.packList[0].oldprice = item.packList[0].marketPrice : '';
              dataInfo.goodsItemV2 = dataInfo.goodsItemV2.concat(item.packList);
            });
            dataInfo.goodsItemV2Object.orderCouponsCode = this.goodsInfo.orderCouponsCode;
            dataInfo.goodsItemV2Object.goodsItem = dataInfo.goodsItemV2;
            return dataInfo.goodsItemV2Object;
          },
        },
        watch: {
          orderData: {
            handler: function(data) {
              dataInfo.init.payAmount = data.payAmount * 100; //变的是底层总金额，原有订单金额不变
              dataInfo.init.goodsInfo.goodsItem = data.goodsList;
              dataInfo.init.activityType = data.activityType;
              dataInfo.init.list = data.goodsList;
            },
            deep: true
          },
        },
      });
      // 初始化数据
      dataInfo.init.getDzInfo(); //校验是否是店主
      dataInfo.getCouponsV3Switch = 1; //获取单品优惠券开关
      if (!dataInfo.init.addressid) { //没有地址id获取默认地址
        dataInfo.init.getDefaulAddressByUser();
      } else if (!!dataInfo.init.addressid) { //有地址id 获取地址id
        dataInfo.init.getAddressDetails();
      };

    },
  };

template.init();
